#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r,k,s1,s2,ans=-1;
	cin>>n>>l>>r;
	if((r-l)>=n){
		cout<<n-1;
		fclose(stdin);
	    fclose(stdout);
	    return 0;
	}
	else{
		for(int i=l;i<=r;i++){
			if(i%n==n-1){
				cout<<n-1;
				fclose(stdin);
	            fclose(stdout);
	            return 0;
				
			}
			else ans=r%n;
		}
	}
	cout<<ans;
	fclose(stdin);
	fclose(stdout);
	return 0;
 } 
